<template>
	<view class="sub-project-detail">
		<view class="detail-item">
			<text class="label">子项目ID：</text>
			<text>{{ subProject.id }}</text>
		</view>
		<view class="detail-item">
			<text class="label">负责人：</text>
			<text>{{ subProject.leader }}</text>
		</view>
		<view class="detail-item">
			<text class="label">状态：</text>
			<text>{{ subProject.status }}</text>
		</view>
		<!-- 可根据实际需求扩展更多展示内容 -->
	</view>
</template>

<script>
	export default {
		data() {
			return {
				subProject: {}
			};
		},
		onLoad(options) {
			try {
				// 1. 先判断参数是否存在
				if (!options || !options.project) {
					throw new Error("未接收到项目数据");
				}
				// 2. 解码并解析（与跳转时的编码对应）
				const decodedProject = decodeURIComponent(options.project);
				this.project = JSON.parse(decodedProject);
			} catch (e) {
				console.error("解析项目数据失败：", e.message);
				// 给用户友好提示
				uni.showToast({
					title: "数据加载失败",
					icon: "none"
				});
				// 可选：返回上一页
				setTimeout(() => {
					uni.navigateBack();
				}, 1500);
			}
		}
	};
</script>

<style scoped>
	.sub-project-detail {
		padding: 20rpx;
	}

	.detail-item {
		margin-bottom: 15rpx;
		display: flex;
		align-items: center;
	}

	.label {
		font-weight: bold;
		margin-right: 10rpx;
	}
</style>